package com.theima.socket;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @program: Myset
 * @description: 发送端
 * @author: xuejingjing
 * @create: 2021-06-24 00:50
 **/
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //1，找码头
        DatagramSocket ds = new DatagramSocket();
        //2，打包礼物
        String s ="送给村长老丈人的礼物";
        byte[] bytes = s.getBytes();
        InetAddress address = InetAddress.getByName("127.0.0.1");
        int port =10000;
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);

        //3，由码头发送包裹
        ds.send(dp);

        //4，付钱走羊
        ds.close();


    }
}
